<?php

/*
 * Successful payment.
 */
include '../config.php';
include '../head.php';
session_start();
$buy_detail_id = $_GET['item_number'];
$amount = $_SESSION['amounts'];
$uid = $_COOKIE['gid'];
$code = $_SESSION['pre_code'];
/*
 * inserting data into buy_products.
 */

mysql_query("insert into salus_buy_product(`id`,`FK_fa_user_id`,`buy_detail_id`,`product_id`,`product_prize`,`date`) values(NULL,'" . $uid . "',$buy_detail_id,'1','" . $amount . "','" . date('Y-m-d') . "') ") or die(mysql_error());


/*
 * creating folders on Me.
 */
$old = umask(0);
//    $dir_path = '/home/salusban/www/salusbank.ch/salusme/storage/';
    $dir_path = '/var/www/html/salusme/storage/';
    mkdir($dir_path . $uid, 0777) or die('Error-me-1');
    mkdir($dir_path . $uid . '/folders', 0777) or die('Error-me-2');
    umask($old);

/*
 * updating pre-paid code table
 */
if($code!=''){
    $code_id = $_SESSION['code_id'];
    mysql_query("update salus_prepaid_codes set user_id='".$uid."' where prepaid_code ='".$code."' ") or die(mysql_error());
}

?>
<title>Successful Payment</title>
<?php include '../header_profile_baby.php'; ?>
<body>
    <div id="wrapper">
        <div id="mainContent">
            Congratulations...!! <br>Your Account created for SalusMe.
        </div>
    </div>
</body>